/*餐饮管理api的页面*/
import request from '@/helpers/request'
import querystring from 'querystring' //序列化请求参数
let formatData = (data)=>{
  return querystring.stringify(data)
}//序列化请求参数 封装函数

const URL = {
  GET_LIST: 'clyd/app/cl/pageList1',
  SAVEROOMTYPE:'clyd/app/cl/saveType',
  SAVEROOM:'clyd/app/cl/saveCar',
  SELECTROOMTYPE:'clyd/app/cl/selectRoomType',
  DELETETYPE:'clyd/app/cl/deleteRoomType',
  DELETEROOMS:'clyd/app/cl/deleteRooms',
  ORDERFORROOMS:'clyd/app/cl/OrderForRooms',
  FINDORDERLIST:'clyd/app/cl/findOrderList',
  DELETETYPE:'clyd/app/cl/deleteType',//删除菜品类别
  deleteByCarsId:'clyd/app/cl/deleteByCarsId',
  pageOrderList:'clyd/app/cl/pageOrderList',//车辆调度接口
  findDriverList:'clyd/app/cl/findDriverList',
  selectJZG:'clyd/app/cl/selectJZG',//查询所有教职工
  driver:'clyd/app/cl/driver',//查司机
  setDriver:'clyd/app/sl/pg',//派单
  applyPageList1:'clyd/app/cl/applyPageList1',//查看所有审核 
  allowApply:'clyd/app/sl/allowApply',//通过与不通过接口
  wg:'clyd/app/sl/wg',//设置订单完成
  saveDriver:'clyd/app/cl/saveDriver',//添加司机
  deleteDriver:'clyd/app/cl/deleteDriver',//删除司机
  findByDdbh:'clyd/app/cl/findByDdbh',//查询订单详情
 ISCARORDERUPDATE:'clyd/app/cl/isCarOrderUpdate',
  CLQX:'clyd/app/cl/clqx',
  SELECTLOGS:"clyd/app/cl/selectLogs",
}

export default {
    getList(page,rows,type,name) {
        return request(URL.GET_LIST, 'POST', formatData({page,rows,type,treeNode:null,name}))
    },//获取宾馆列表
    saveType(name) {
        return request(URL.SAVEROOMTYPE, 'POST', formatData({name}))
    },//保存宾馆类型
    saveCar(form) {
        return request(URL.SAVEROOM, 'POST', formatData(form))
    },//保存房间
    selectRoomType(){
        return request(URL.SELECTROOMTYPE, 'POST', formatData({}))
    },//获取宾馆类型
    deleteRoomType(ids){
        return request(URL.DELETETYPE, 'POST', formatData({ids}))
    },//删除宾馆类型
    deleteRooms(type,refe){
        return request(URL.DELETEROOMS, 'POST', formatData({type,refe}))
    },//删除宾馆房间
    orderForRooms(type,refe,time,count){
        return request(URL.ORDERFORROOMS, 'POST', formatData({type,refe,time:time+'',count}))
    },//设置满房
    findOrderList(page,rows){
        return request(URL.FINDORDERLIST, 'POST', formatData({page,rows}))
    },//查找订单列表,
    deleteType(ids){
        return request(URL.DELETETYPE, 'POST',formatData({ids}))
    },
    deleteByCarsId(ids){
        return request(URL.deleteByCarsId, 'POST',formatData({ids}))
    },
    pageOrderList(page,rows,status,input,index){
        return request(URL.pageOrderList, 'POST',formatData({page,rows,status,input,index}))
    },
    findDriverList(page,rows,status){
        return request(URL.findDriverList, 'POST',formatData({page,rows,status}))
    },
    selectJZG(page,rows,xm){
        return request(URL.selectJZG, 'POST',formatData({page:0,rows:10,xm}))
    },
    driver(time1,time2,flag){
        let month1 = (new Date(time1).getMonth() + 1) < 10 ? '0' + (new Date(time1).getMonth() + 1) : (new Date(time1).getMonth() + 1)
        let date1 = new Date(time1).getDate() < 10 ? '0' + new Date(time1).getDate() : new Date(time1).getDate()
        time1 = new Date(time1).getFullYear() + month1 + date1
        if(time2==null){
            time2=null
        }else{
            let month2 = (new Date(time2).getMonth() + 1) < 10 ? '0' + (new Date(time2).getMonth() + 1) : (new Date(time2).getMonth() + 1)
            let date2 = new Date(time2).getDate() < 10 ? '0' + new Date(time2).getDate() : new Date(time2).getDate()
            time2 = new Date(time2).getFullYear() + month2 + date2
        }
        return request(URL.driver, 'POST',formatData({time1,time2,flag}))
    },
    setDriver(orderId,driverId){
        return request(URL.setDriver, 'POST',formatData({orderId,driverId}))
    },
    applyPageList1(page,rows){
        return request(URL.applyPageList1, 'POST',formatData({page,rows}))
    },
    allowApply(form){
        return request(URL.allowApply, 'POST',formatData(form))
    },
    wg(orderId){
        return request(URL.wg, 'POST',formatData({orderId}))
    },
    saveDriver(form){
        return request(URL.saveDriver, 'POST',formatData(form))
    },
    deleteDriver(ids){
        return request(URL.deleteDriver, 'POST',formatData({ids}))
    },
    findByDdbh(ddbh){
        return request(URL.findByDdbh, 'POST',formatData({ddbh}))
    },
    isCarOrderUpdate(id,type){
        return request(URL.ISCARORDERUPDATE, 'POST', formatData({id,type}))
    },//是否预订
    clqx(orderId){
        return request(URL.CLQX, 'POST', formatData({orderId}))
    },//是否预订
    selectLogs(page,rows,username,){
        return request(URL.SELECTLOGS,'POST',formatData({page,rows,username,}))  
        
    }
   

}